<?php

namespace app\common\model\user;

use think\Model;

class User extends Model
{
    protected $hidden = ['account', 'password'];

    public function profile()
    {
        return $this->hasOne('UserProfile')
            ->bind('nickname,avatar,cover,what_is_up');
    }

    public function weixin()
    {
        return $this->hasOne('UserWeixin')
            ->bind([
                'weixin_url' => 'url',
                'weixin_desc' => 'desc'
            ]);
    }

    public function statistics()
    {
        return $this->hasOne('UserStatistics')
            ->bind('view_count,article_count');
    }

    public function tag()
    {
        return $this->hasMany('UserTag');
    }

    public function saying()
    {
        return $this->hasOne('UserSaying')
            ->bind([
                'saying_text' => 'text'
            ]);
    }

    public function auth()
    {
        return $this->belongsToMany('app\\common\\model\\auth\\AuthGroup', 'UserAccessAuthGroup');
    }

    public function article()
    {
        return $this->hasMany('app\\common\\model\\article\\Article');
    }

    public function book()
    {
        return $this->hasMany('app\\common\\model\\book\\Book');
    }

    public function invite()
    {
        return $this->hasOne('UserInvite');
    }
}
